﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoreLibrary.Utility
{
    public static class Chance
    {
        private static Random r = new Random();
        public static int SelectRandom(int minValue, int maxValue)
        {
            return r.Next(minValue, maxValue + 1);
        }

        public static bool EventOccurs(double percent)
        {
            double convertPercent = percent / 100.0;
            return r.NextDouble() < convertPercent;
        }

        public static T SelectRandomValue<T>(List<T> valueList)
        {
            int index = r.Next(0, valueList.Count);

            return valueList[index];
        }

        public static T SelectRandom<T>(this List<T> list)
        {
            return SelectRandomValue(list);
        }
    }
}
